<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
    <!--    用于解析ES6-->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <style>
        .red {
            color: red;
        }
    </style>
</head>
<!--ES6 -->
<!--条件处理-->
<body>
<div id="app"></div>
<script type="text/babel">

    function Login(){
        return <button>Login</button>
    }
    function Logout(){
        return <button>Logout</button>
    }
    class Template extends React.Component {
        state = {
            isLogin: false,
        }

        updateInfo = () => {
            this.setState({
                isLogin: !this.state.isLogin
            })
        }

        render(){
            const {isLogin} = this.state

            return <div>
                <button onClick={this.updateInfo}>更新数据</button>
                {isLogin ? <Login/> : <Logout/>}
            </div>
        }
    }
    ReactDOM.render(<Template/>,document.getElementById('app'))
</script>
</body>
</html>